package com.ustc.py.learn.dao;

import com.ustc.py.learn.entity.Knowledge;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface KnowledgeDao {
    /**
     * 根据knowledge类型查询列表
     * @param type
     * @return
     */
    @Select("SELECT * FROM knowledge WHERE type = #{type} ORDER BY knowledge.chapter_id ASC ")
    List<Knowledge> selectByType(@Param("type") Integer type);

    /**
     * 根据知识类型和章节号查询knowledgeId主键
     * @param knowledgeType
     * @param chapterIds
     * @return
     */
    List<Integer> getKnowledgeIdsByKnowledgeTypeAndChapterIds(@Param("knowledgeType") int knowledgeType, @Param("chapterIds") List<Integer> chapterIds);

    /**
     * 根据知识类型获取全部信息
     * @param knowledgeType
     * @return
     */
    @Select("SELECT id, type, chapter_id, title,text FROM `knowledge` WHERE type = #{knowledgeType}")
    List<Knowledge> queryKnowledgesByType(@Param("knowledgeType") int knowledgeType);
}
